import 'package:flutter/material.dart';

class HomeNav extends StatelessWidget {
const   HomeNav({ super.key });

  @override
  Widget build(BuildContext context){
    // 导航数据
  List navList = [
    {
      "name": 'house',
      'title': '我的房屋',
      'icon': 'assets/images/house_nav_icon@2x.png',
    },
    {
      "name": 'fix',
      'title': '我的报修',
      'icon': 'assets/images/repair_nav_icon@2x.png',
    },
    {
      "name": 'travel',
      'title': '访客登记',
      'icon': 'assets/images/visitor_nav_icon@2x.png',
    }
  ];

  getChildren(){
    return navList.map((item) {
      return Expanded(
        child: GestureDetector(
            onTap: () {
              if (item["name"] == 'house') {
                Navigator.pushNamed(context, '/HouseList');
              }
            },
            child: Column(
              children: [
                Image.asset(
                  item['icon'],
                  width: 35,
                ),
                Text(item['title']),
              ],
            )),
      );
    }).toList();  
  }

    return Container(
      margin: const EdgeInsets.only(top: 10,bottom: 10),
      padding: const EdgeInsets.only(left: 10,right: 10),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: getChildren(),
      ),
    );
  }
}